package dome5接口练习;

public class C {
    public void  powerOn() {
        System.out.println("开机");
    }

    public void  powerOff() {

        System.out.println("关机");
    }

    public void useDevice(F usb) {
        usb.openDevice();
        if(usb instanceof A) {
            A a = (A)usb;
            a.click();
        } else if (usb instanceof B) {
            B b = (B)usb;
            b.click();
        }
        usb.closeDevice();
    }
}

class Test {
    public static void main(String[] args) {
        C c = new C();

        c.powerOn();
        c.useDevice(new A());
        c.useDevice(new B());
        c.powerOff();
    }
}
